package com.jake.groovy.ex2;
import javax.swing.JOptionPane;

public class SDEGui {

    public static void main(String[] args) {
        SDEGui sdegui =  new SDEGui();
        sdegui.startGui();
    }

    private void startGui() {
        final SDEGuiWindow window = SDEGuiWindow.getInstance();  // Create the whole "GUI"
        window.show();

        Workspace workarea = SettingManager.getCurrentWorkspace();   // Create the workarea, the object to be scripted

        // starting the Groovy interpreter
        try {
            startScript(workarea, window);
        }
        catch (Exception e) {
               JOptionPane.showMessageDialog(window, "Exception in groovy script connection: " + e.getMessage(),
                                             "Groovy-error", JOptionPane.WARNING_MESSAGE);
        }
    }

    // Starts the standard Groovy script to setup additional (customised) gui elements
    private void startScript(final Workspace workarea, final SDEGuiWindow window) {

        ScriptConnector connector = new ScriptConnector(workarea, window);   // instanciate the connector ...
        connector.runGuiComponentScript("plugins.groovy");                   // ... and run the plugin script

        window.show();
    }
}